// pages/divination/divination-detail/divination-detail.js
let app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    detail:{
      rep_createtime:"",
      rep_year_branch:"",
      rep_month_branch:"",
      rep_day_branch:"",
      rep_bazishizhu:"",
      rep_category:""
    },
    sixItems:[],
    recommends:[]
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    wx.showLoading({
      title: '正在加载中',
    })
    console.log("dddd",options)
    let id = options.resultId
    app.request("get_report", { rep_id: id }).then((data) => {
      this.setData({
        sixItems: data.report.reverse(),
        detail: data.reports
      })
    }).then(()=>{
      app.request("get_applets").then((data) => {
        let recommends = data.category.filter((item, index) => {
          return item.app_recommend == 1
        })
        this.setData({
          recommends: recommends
        })
        wx.hideLoading()
        console.log(recommends)
      })
    })

  },


  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
    wx.setNavigationBarTitle({
      title: "解卦详情"
    })
  },
  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
  },
  navToApp(e) {
    let id = e.currentTarget.dataset.id
    console.log(id)
    wx.navigateToMiniProgram({
      appId: id,
      fail(err) {
        wx.showToast({
          title: '正在开发中~',
          duration: 900
        })
      }
    })
  },
  onShareAppMessage: function (res) {
    return {
      title: '每日一卦',
      path: '/pages/divination/divination',
      success: function (res) {
        // 转发成功
      },
      fail: function (res) {
        // 转发失败
      }
    }
  }
})